import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { basInvListData } from '/@/api/bas/inv/basInv';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('存货选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('存货编码'),
      field: 'cinvcode',
      component: 'Input',
    },
    {
      label: t('存货名称'),
      field: 'cinvname',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('存货编码'),
    dataIndex: 'cinvcode',
    key: 'a.cinvcode',
    sorter: true,
    width: 160,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('存货名称'),
    dataIndex: 'cinvname',
    key: 'a.cinvname',
    sorter: true,
    align: 'left',
    width: 240,
  },
  {
    title: t('规格型号'),
    dataIndex: 'cinvstd',
    key: 'a.cinvstd',
    sorter: true,
    width: 100,
  },
  {
    title: t('存货代码'),
    dataIndex: 'cinvaddcode',
    key: 'a.cinvaddcode',
    sorter: true,
    width: 100,
  },
  {
    title: t('分类代码'),
    dataIndex: 'invCls.name',
    key: 'a.cls_code',
    sorter: true,
    width: 100,
  },
  {
    title: t('单位'),
    dataIndex: 'unitName',
    key: 'a.unit_name',
    sorter: true,
    width: 100,
  },
  {
    title: t('税率'),
    dataIndex: 'itaxrate',
    key: 'a.itaxrate',
    sorter: true,
    width: 100,
  },
  {
    title: t('参考售价'),
    dataIndex: 'iinvscost',
    key: 'a.iinvscost',
    sorter: true,
    width: 100,
  },
  {
    title: t('最低售价'),
    dataIndex: 'iinvlscost',
    key: 'a.iinvlscost',
    sorter: true,
    width: 100,
  },
  {
    title: t('零售单价'),
    dataIndex: 'iinvsalecost',
    key: 'a.iinvsalecost',
    sorter: true,
    width: 100,
  },
  {
    title: t('零售价格'),
    dataIndex: 'fretailprice',
    key: 'a.fretailprice',
    sorter: true,
    width: 100,
  },
  {
    title: t('是否发布'),
    dataIndex: 'fbStatus',
    key: 'a.fb_status',
    sorter: true,
    width: 100,
    dictType: 'shop_fb_status',
  },
];

const tableProps: BasicTableProps = {
  api: basInvListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    //params['ope'] = '1';
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'cinvcode',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'cinvcode',
  itemName: 'cinvname',
};
